﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using TSVNAddin.SVN;
using EnvDTE;
using EnvDTE80;

namespace TSVNAddin.Core.Test
{
	[TestFixture]
	public class RepositoryPathFinderFixture
	{
		[Test]
		public void FindRootPath()
		{
			string fileName = @"c:\svn\myproject\trunk\file.txt";
			string reposiotryPath = @"c:\svn\myproject";

			var svnClientAdapter = MockRepository.GenerateMock<SVNClientAdapter>();
			svnClientAdapter.Stub(x => x.GetRepositoryPath(fileName)).Return(reposiotryPath);

			var solution = MockRepository.GenerateMock<Solution>();
			solution.Stub(x => x.FileName).Return(fileName);

			var applicationObject = MockRepository.GenerateMock<DTE2>();
			applicationObject.Stub(x => x.Solution).Return(solution);

			RepositoryPathFinder finder = new RepositoryPathFinder(svnClientAdapter);
			string retRepositoryPath = finder.FindRootPath(applicationObject);

			Assert.AreEqual(reposiotryPath, retRepositoryPath);
		}
	}
}
